package c.c.a;

import android.content.Context;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;

public final class a1 implements d1 {
    public p0<Boolean> a = new a(this);

    public class a extends p0<Boolean> {
        public a(a1 a1Var) {
        }

        public Object a(Object[] objArr) {
            boolean z = false;
            try {
                PackageManager packageManager = ((Context) objArr[0]).getPackageManager();
                if (packageManager != null) {
                    if (packageManager.resolveContentProvider("com.meizu.flyme.openidsdk", 0) != null) {
                        z = true;
                    }
                    return Boolean.valueOf(z);
                }
            } catch (Exception unused) {
            }
            return Boolean.FALSE;
        }
    }

    public boolean a(Context context) {
        if (context == null) {
            return false;
        }
        return ((Boolean) this.a.b(context)).booleanValue();
    }

    public c.c.a.d1.a b(Context context) {
        Throwable th;
        Cursor query;
        try {
            query = context.getContentResolver().query(Uri.parse("content://com.meizu.flyme.openidsdk/"), null, null, new String[]{"oaid"}, null);
            if (query == null) {
                if (query != null) {
                    query.close();
                }
                return null;
            }
            try {
                String string;
                c.c.a.d1.a aVar = new c.c.a.d1.a();
                if (!query.isClosed()) {
                    query.moveToFirst();
                    int columnIndex = query.getColumnIndex("value");
                    if (columnIndex >= 0) {
                        string = query.getString(columnIndex);
                        aVar.a = string;
                        query.close();
                        return aVar;
                    }
                }
                string = null;
                aVar.a = string;
                query.close();
                return aVar;
            } catch (Throwable th2) {
                th = th2;
                try {
                    th.printStackTrace();
                    return null;
                } finally {
                    if (query != null) {
                        query.close();
                    }
                }
            }
        } catch (Throwable th3) {
            th = th3;
            query = null;
            th.printStackTrace();
            return null;
        }
    }
}
